package com.pig.graduate.controller.produce;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pig.graduate.common.exception.MyException;
import com.pig.graduate.domain.event.EventEntry;
import com.pig.graduate.domain.event.EventExit;
import com.pig.graduate.domain.event.EventTransferDormitory;
import com.pig.graduate.domain.produce.ProduceBoar;
import com.pig.graduate.result.MyResult;
import com.pig.graduate.service.event.EventEntryService;
import com.pig.graduate.service.event.EventTransferDormitoryService;
import com.pig.graduate.service.produce.ProduceBoarService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Date;
import java.util.List;

@Api(tags = {"种猪管理"}, description = "种猪管理")
@RestController
@RequestMapping("/produce/boar")
public class ProduceBoarController {

    @Autowired
    private ProduceBoarService produceBoarService;


    /**
     * 种猪列表
     * @param produceBoar
     * @return
     */
    @ApiOperation(value = "种猪列表",notes = "种猪列表")
    @PostMapping("/list")
    public MyResult boarList(@RequestBody ProduceBoar produceBoar){
        // 查询所有栋舍信息
        return produceBoarService.boarList(produceBoar);
    }

    /**
     * 进场
     * @param produceBoar
     * @return
     */
    @ApiOperation(value = "种猪进场",notes = "种猪进场")
    @PostMapping("/boarEntry")
    public MyResult boarEntry(@RequestBody @Valid ProduceBoar produceBoar){
        return produceBoarService.boarEntry(produceBoar);
    }

    /**
     * 转舍
     * @param eventTransferDormitory
     * @return
     */
    @ApiOperation(value = "种猪转舍",notes = "种猪转舍")
    @PostMapping("/boarMoveBuildings")
    public MyResult boarMoveBuildings(@RequestBody @Valid EventTransferDormitory eventTransferDormitory){
        return produceBoarService.boarMoveBuildings(eventTransferDormitory);
    }




    /**
     * 种猪离场
     * @param eventExit
     * @return
     */
    @ApiOperation(value = "种猪离场",notes = "种猪离场")
    @PostMapping("/boarLeave")
    public MyResult boarLeave(@RequestBody EventExit eventExit){
        return produceBoarService.boarLeave(eventExit);
    }

    /**
     * 种猪删除
     * @param id
     * @return
     */
    @ApiOperation(value = "种猪删除",notes = "种猪删除")
    @DeleteMapping("/boarDelete/{id}")
    public MyResult boarDelete(@PathVariable(value = "id")Long id){
        produceBoarService.removeById(id);
        return MyResult.success("删除成功");
    }

}
